package com.gdupt.until;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

import java.io.Serializable;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResponseData{
    private Integer code;
    private String msg;
    private Object data;
    private Long count;

    private static final String SUCCESS = "success";
    private static final String FAIL = "fail";

    private ResponseData(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private ResponseData(Integer code,Long count, Object data) {
        this.code = code;
        this.count = count;
        this.data = data;
    }

    public static ResponseData okData(Object data){
        return new ResponseData(0, ResponseData.SUCCESS,data);
    }

    public static ResponseData okPage(Long count,Object data){
        return new ResponseData(0,count,data);
    }

    public static ResponseData okMessage(String msg){
        return new ResponseData(0,msg,null);
    }

    public static ResponseData fail(){
        return new ResponseData(1, ResponseData.FAIL,null);
    }

    public static ResponseData fail(String msg){
        return new ResponseData(1,msg,null);
    }



}
